﻿using RockBus.Configuration.Interfaces;
using RockBus.PerformanceCounters.Interfaces;
using RockBus.Queueing.Interfaces;
using System;
using System.Threading.Tasks.Dataflow;

namespace RockBus.Queueing.TplDataflow
{
    public class QueueFactory : IQueueFactory
    {
        public QueueFactory(IReadOnlyConfiguration configuration, IPerformanceCounterFactory performanceCounterFactory)
        {
            this.Configuration = configuration;
            this.PerformanceCounterFactory = performanceCounterFactory;
        }

        private IReadOnlyConfiguration Configuration { get; set; }

        private IPerformanceCounterFactory PerformanceCounterFactory { get; set; }

        public IQueue<T> CreateQueue<T>(string name, Action<T> dequeueAction)
        {
            return new ActionBlockQueue<T>(this.Configuration, this.PerformanceCounterFactory, name, dequeueAction);
        }
    }
}